function parseSF(rawtext) {
    // alert("Starting SF Parser");

    // trim carriage returns
    rawtext = rawtext.replace(/\r/gm,"")

    // remove blank lines
    rawtext = rawtext.replace(/[\s\r\n]+$/, '');

    // generate an array of file lines
    sftext = rawtext.split(/\n/gm);


    var bonds = [];
    var angles = [];
    var torsions = [];

    // parse each line
    for (i=0; i<sftext.length; i++) {

        //split each line into an array based on whitespace delimiting
        curline = sftext[i].split(/\s+/);

        //record is the first element of the current line array
        var record = curline[0]


        if (record.match("BOND")) {

            //Get the indices of the 2 atoms involved in the bond
            tatom0 = curline[1];
            tatom1 = curline[2];
            
            tconstant = curline[3];
            tequilibrium = curline[4];

            // atoms are 1-indexed in the input files, but SOFIA needs them 0-indexed
            var bond = {
                atoms: [parseFloat(tatom0)-1,parseFloat(tatom1)-1],
                constant: parseFloat(tconstant),
                equilibrium: parseFloat(tequilibrium)
            };

            bonds.push(bond);
        }

        else if (record.match("ANGLE")) {

            //Get the indices of the 3 atoms involved in the angle
            tatom0 = curline[1];
            tatom1 = curline[2];
            tatom2 = curline[3];

            tconstant = curline[4];
            tequilibrium = curline[5];

            var angle = {
                atoms: [parseFloat(tatom0)-1,parseFloat(tatom1)-1,parseFloat(tatom2)-1],
                constant: parseFloat(tconstant),
                equilibrium: parseFloat(tequilibrium)
            };

            angles.push(angle);
        }
        else if (record.match("TORSION")) {

            //Get the indices of the 4 atoms involved in the torsion
            tatom0 = curline[1];
            tatom1 = curline[2];
            tatom2 = curline[3];
            tatom3 = curline[4];

            tconstant = curline[5];
            tequilibrium = curline[6];

            var torsion = {
                atoms: [parseFloat(tatom0)-1,parseFloat(tatom1)-1,parseFloat(tatom2)-1,parseFloat(tatom3)-1],
                constant: parseFloat(tconstant),
                equilibrium: parseFloat(tequilibrium)
            };

            torsions.push(torsion);
        }
        else {}
    }

    trajectory.bonds = bonds;
    trajectory.angles = angles;
    trajectory.torsions = torsions;

    //return [bonds,angles,torsions];


}